package IOStreamStudy.charSetQuestion;

/**
 * 编码有问题,对编码进性修改,
 * 1:用FileInputStream将文件读取为字节流
 * ******2:用InputStreamReader转换成字符流,同时改变编码
 * 3:用BufferedReader对字符流进行操作
 * */

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

public class CharSetReadDemo {
    public static void main(String[] args) throws IOException {
        String filePath = "D:\\all_projects\\java_projects\\java_ij\\springMVC\\NetWork\\src" +
                "\\cn\\usts\\edu\\IOStreamStudy\\charSetQuestion\\a.txt";
        // 将字节流转换成字符流,改变编码
        InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(filePath),"gbk");
        // 对字符流进行读取
        BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
        String line;
        while ((line = bufferedReader.readLine())!=null){
            System.out.println(line);
        }
        bufferedReader.close();
    }
}
